﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Ordering.Domain.AggregatesModel.OrderAggregate;
using System;
using System.Collections.Generic;
using System.Text;

namespace Ordering.Infrastructure.EntityConfigurations
{
    public class AddressEntityTypeConfiguration
                : IEntityTypeConfiguration<Address>
    {
        public void Configure(EntityTypeBuilder<Address> builder)
        {
            builder.ToTable("address", OrderingContext.DEFAULT_SCHEMA);

            builder.HasKey(ci => ci.Id);

            builder.Property(ci => ci.Id)
               .UseHiLo("addressseq", OrderingContext.DEFAULT_SCHEMA)
               .IsRequired();

            builder.Property(cb => cb.Province)
               .IsRequired(true);
            builder.Property(cb => cb.City)
               .IsRequired(true);
            builder.Property(cb => cb.Area)
               .IsRequired(true);
            builder.Property(cb => cb.DetailedAddress)
               .IsRequired(false);
            builder.Property(cb => cb.Latitude)
               .IsRequired(false);
            builder.Property(cb => cb.ExtendField)
               .IsRequired(false);
            builder.Property(cb => cb.Town)
              .IsRequired(false);
            builder.Property(cb => cb.Longitude)
               .IsRequired(true);
            
        }
    }
}
